<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>根据当前时间显示问候</title>
	</head>
	<body>
		<div id="myclock">
		<script type="text/javascript">
			
			function my_clock(){
				var now=new Date();            //获得当前时间
				var year=now.getFullYear();   //获得年份
				var month=now.getMonth();     //获得月份
				var day=now.getDate();         //获得天数
				var week=now.getDay();       //获得星期
				var hours=now.getHours();     //获得小时
				var minutes=now.getMinutes();  //分钟
				var seconds=now.getSeconds();   //获得当前秒数
				var h,w;
				if(hours>=6&&hours<=12){
					h="上午好";
				}else if(hours>12&&hours<=14){
					h="中午好！";
				}else if(hours>14&&hours<=18){
					h="下午好！";
				}else if(hours>18){
					h="晚上好！";
				}else{
					h="现在是凌晨!";
				}
				
				if(week==0){
					w="星期日";
				}else if(week==1){
					w="星期一";
				}else if(week==2){
					w="星期二";
				}else if(week==3){
					w="星期三";
				}else if(week==4){
					w="星期四";
				}else if(week==5){
					w="星期五";
				}else if(week==6){
					w="星期六";
				}
							
				document.getElementById("myclock").innerHTML="今天日期："
				+year+"年"+(month+1)+"月"+day+"日"+"<br/>"+"现在时间"+hours+"点"+minutes+
				"分"+seconds+"秒"+"<br/>"+h+"欢迎来到贵美！";
			}
			var mytime=setInterval("my_clock()",1000);
		</script>
	   </div>
	</body>
</html>

